SciChart WPF 2D Charts > ChartModifier API > Cursors, Tooltips and legends > TernaryChartModifiers > Ternary Cursor Modifier
Ternary Cursor Modifier

SciChart features a Cursor or Crosshairs modifier provided by the TernaryCursorModifier for the ternary chart. This is able to display a crosshairs at the mouse-location and XAxis, YAxis or ZAxis labels.

The TernaryCursorModifier is demonstrated in the example 2D Charts > Create a Ternary Chart > Polygon Series TernaryChart

   

Adding a TernaryCursorModifier to the Chart – Xaml

Please see the code sample below for how to add a TernaryCursorModifier to a SciChartTernarySuface

Adding a TernaryCursorModifier to the Chart
Copy Code
<!-- where xmlns:s="http://schemas.abtsoftware.co.uk/scichart" -->
<s:SciChartTernarySurface>
    <s:SciChartTernarySurface.ChartModifier>
        <s:TernaryModifierGroup>
            <s:TernaryCursorModifier x:Name="ternaryCursorModifier"
               IsEnabled="True"
                                     ShowAxisLabels="True" />           
        </s:TernaryModifierGroup>
    </s:SciChartTernarySurface.ChartModifier>
</s:SciChartTernarySurface>

Adding a TernaryCursorModifier to the Chart – Code

The equivalent code to add a TernaryCursorModifier in C# is as follows:

Adding a TernaryCursorModifier to the Chart
Copy Code
var sciChartTernarySurface = new SciChartTernarySurface
{
    ChartModifier = new TernaryModifierGroup(new TernaryCursorModifier
    {
        IsEnabled = true,
        ShowAxisLabels = true
    })
};

Showing or Hiding Axis Labels

The TernaryCursorModifier shows optional labels on the X, Y and Z Axis. These can be disabled by setting the TernaryCursorModifier.ShowAxisLabels property to false.

Styling the TernarryCursorModifier Crosshair Lines

The crosshair lines provided by the TernaryCursorModifier can be styled by setting the TernaryCursorModifier.LineOverlayStyle property. This expects a Style with TargetType = System.Windows.Shapes.Line.

For example:

Styling the TernarryCursorModifier Crosshair Lines
Copy Code
 <!-- Demonstrates custom cursor line style -->
<s:SciChartTernarySurface>
    <s:SciChartTernarySurface.Resources>
        <Style x:Key="TernaryCursorLineStyle" TargetType="Line">
            <Setter Property="StrokeThickness" Value="2" />
            <Setter Property="Stroke" Value="Red " />
            <Setter Property="StrokeDashArray" Value="2 2" />
        </Style>
    </s:SciChartTernarySurface.Resources>
     <s:SciChartTernarySurface.ChartModifier>
         <s:TernaryModifierGroup>
             <s:TernaryCursorModifier x:Name="ternaryCursorModifier" LineOverlayStyle="{StaticResource TernaryCursorLineStyle}" />
         </s:TernaryModifierGroup>
     </s:SciChartTernarySurface.ChartModifier>
</s:SciChartTernarySurface>

Styling the Axis Labels

TernaryCursorModifier Axis Labels come with a default style. This style can be overridden by setting the TernaryCursorModifier.AxisLabelContainerStyle and/or TernaryCursorModifier.AxisLabelTemplate attached properties on the relevant axis.

For example:

Styling the Axis Labels
Copy Code
<!--  Demonstrates custom cursor axis label style  -->
<s:SciChartTernarySurface>
    <s:SciChartTernarySurface.Resources>
        <!--  This is the style for the control that hosts the Axis Label  -->
        <Style x:Key="TernaryCursorModAxisLabelStyle" TargetType="s:AxisLabelControl">
            <Setter Property="Background" Value="Red" />
            <Setter Property="BorderBrush" Value="#FFFF6600" />
            <Setter Property="BorderThickness" Value="1" />
        </Style>
 
        <!-  This is the DataTemplate for the Axis Label. DataContext is AxisInfo -->
        <DataTemplate x:Key="TernaryCursorModAxisLabelTemplate" DataType="s:AxisInfo">
            <StackPanel>
                <TextBlock Margin="2"
                           FontFamily="Arial"
                           FontSize="25"
                           Foreground="White"
                           Text="{Binding DataValue,
                                          StringFormat='{}{0:0.00}'}" />
            </StackPanel>
        </DataTemplate>
    </s:SciChartTernarySurface.Resources>
 
    <!--  Declare Axes Styles with CursorLabelTemplates  -->
    <s:SciChartTernarySurface.XAxisStyle>
        <Style TargetType="s:TernaryNumericAxis">
            <Setter Property="s:TernaryCursorModifier.AxisLabelContainerStyle" Value="{StaticResource TernaryCursorModAxisLabelStyle}" />
            <Setter Property="s:TernaryCursorModifier.AxisLabelTemplate" Value="{StaticResource TernaryCursorModAxisLabelTemplate}" />
        </Style>
    </s:SciChartTernarySurface.XAxisStyle>
    <s:SciChartTernarySurface.YAxisStyle>
        <Style TargetType="s:TernaryNumericAxis">
            <Setter Property="s:TernaryCursorModifier.AxisLabelContainerStyle" Value="{StaticResource TernaryCursorModAxisLabelStyle}" />
            <Setter Property="s:TernaryCursorModifier.AxisLabelTemplate" Value="{StaticResource TernaryCursorModAxisLabelTemplate}" />
        </Style>
    </s:SciChartTernarySurface.YAxisStyle>
    <s:SciChartTernarySurface.ZAxisStyle>
        <Style TargetType="s:TernaryNumericAxis">
            <Setter Property="s:TernaryCursorModifier.AxisLabelContainerStyle" Value="{StaticResource TernaryCursorModAxisLabelStyle}" />
            <Setter Property="s:TernaryCursorModifier.AxisLabelTemplate" Value="{StaticResource TernaryCursorModAxisLabelTemplate}" />
        </Style>
    </s:SciChartTernarySurface.ZAxisStyle>
 
    <s:SciChartTernarySurface.ChartModifier>
        <s:TernaryModifierGroup>
            <s:TernaryCursorModifier ShowAxisLabels="True" />
        </s:TernaryModifierGroup>
    </s:SciChartTernarySurface.ChartModifier>
</s:SciChartTernarySurface>